/**
  ******************************************************************************
  * @file           : ANOv4.h
  * @brief          : 匿名地面站v4通信协议
  ******************************************************************************
  * @attention		
  *
  * @Logs:
  * Date           Author       Notes
  * 2022-04-09     李树益      第一个版本
  ******************************************************************************
  */
	
#ifndef _ANO_V4_H_
#define _ANO_V4_H_

#define ANO_RX_BUF_LEN  64

#if ANO_RING_BUFF
#include "RingBuffer.h"
#endif

struct ano_flag
{
    unsigned int send_start : 1;
	unsigned int send_version : 1;
	unsigned int send_status : 1;
	unsigned int send_senser : 1;
	unsigned int send_pid1 : 1;
	unsigned int send_pid2 : 1;
	unsigned int send_pid3 : 1;
	unsigned int send_pid4 : 1;
	unsigned int send_pid5 : 1;
	unsigned int send_pid6 : 1;
	unsigned int send_rcdata : 1;
	unsigned int send_offset : 1;
	unsigned int send_motopwm : 1;
	unsigned int send_power : 1;
};

typedef struct
{
    void (*send)(unsigned char *buf, unsigned short size);    //发送数据的函数
    struct ano_flag dt_flag;                                  //发送标志
    unsigned char rx_buf[ANO_RX_BUF_LEN];                     //接收缓冲
#if ANO_RING_BUFF
    RingBuffer ringbuff;
#endif
}ANOv4;

void ANO_Init(ANOv4 *ano, void (*send)(unsigned char *buf, unsigned short size));
void ANO_DT_Data_Receive_Prepare(ANOv4 *ano, unsigned char data);
void ANO_DT_Data_Receive_Anl(ANOv4 *ano, unsigned char *data_buf,unsigned char num);
void ANO_DT_Send_Version(ANOv4 *ano, unsigned char hardware_type, unsigned char hardware_ver,unsigned char software_ver,unsigned char protocol_ver,unsigned char bootloader_ver);
void ANO_DT_Send_Status(ANOv4 *ano, float angle_rol, float angle_pit, float angle_yaw, int alt, unsigned char fly_model, unsigned char armed);
void ANO_DT_Send_Senser(ANOv4 *ano, short a_x,short a_y,short a_z,short g_x,short g_y,short g_z,short m_x,short m_y,short m_z,short bar);
void ANO_DT_Send_RCData(ANOv4 *ano, unsigned short thr,unsigned short yaw,unsigned short rol,unsigned short pit,unsigned short aux1,unsigned short aux2,unsigned short aux3,unsigned short aux4,unsigned short aux5,unsigned short aux6);
void ANO_DT_Send_Power(ANOv4 *ano, float votage, float current);
void ANO_DT_Send_MotoPWM(ANOv4 *ano, unsigned short m_1,unsigned short m_2,unsigned short m_3,unsigned short m_4,unsigned short m_5,unsigned short m_6,unsigned short m_7,unsigned short m_8);
void ANO_DT_Send_PID(ANOv4 *ano, unsigned char group,float p1_p,float p1_i,float p1_d,float p2_p,float p2_i,float p2_d,float p3_p,float p3_i,float p3_d);

#endif

